// const man = {
//     name: "Tom",
//     age: 12
//   }
  
//   const proxy = new Proxy(man, {
//     get: (target, name) => {
//       if (name in target) {
//         return target[name]
//       } else {
//         throw new Error (`Property ${property} does not exist`)
//       } 
//     }
//   })
  
//   console.log(proxy.name)
//   console.log(proxy.age, proxy.location)

  const man = {
    name: 'jscoder',
    age: 22
  }
  
  // 补全代码
  const proxy = new Proxy(man, {
    // target: 被代理的目标对象
    // property：访问的属性名称
    get (target, property) {
      if (property in target) {
        return target[property]
      }
      throw new Error(`Property "${property}" does not exist`)
    }
  })
                          
  console.log(proxy.name) // "jscoder"
  console.log(proxy.location) // 22
                          